<template>
    <div class="commont">
        <h3>发表评论</h3>
        <hr>
        <textarea placeholder="请输入评论" v-model="msg"></textarea>
        <mt-button type="primary" size="large" @click="postCommont">发表评论</mt-button>
        <div>
            <dl v-for="(value,i) in pinglun" :key="i">
                <dt>第{{i+1}}楼 用户:匿名用户 发表时间:{{commonts.datetime}}</dt>
                <dd>{{value=='1'?"此用户很懒,什么都没说":value}}</dd>
            </dl>

        </div>
        <mt-button type="danger" size="large" plain>加载更多</mt-button>

    </div>
</template>
<script>
import { Toast } from 'mint-ui';
export default {
    data() {
        return {
            id:this.$route.query.sid,
            commonts:[],
            pinglun:[],
            msg:""
        }
    },
    methods: {
        getcommonts(){
             this.axios(
                "http://10.31.162.198/1810-3/Vue/vue-cms/src/lib/PHP/newsinfo.php?sid="+this.id,
                {sid:this.id},
            ).then(res=>{
                this.commonts=res.data;
                this.pinglun=JSON.parse(this.commonts.commont)
                // console.log(this.pinglun)
            })
        },
        postCommont(){
            Toast("哈哈哈,没想到吧,我是假的!!")
            this.msg=""
        }
    },
    created(){
        this.getcommonts()
    }
}
</script>
<style lang="scss" scoped>
.commont{
    h3{
        text-align: center;
        font-size: 16px;
    }
    textarea{
         font-size: 14px;
         margin-bottom: 0;
    }
    dl{
        font-size: 13px;
        margin: 5px 0;
        dt{
        background: #ccc;
        }
        dd{
            line-height: 28px;
        }
    }

    .mint-button--primary{
    background-color: chocolate
    }
}

</style>
